/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.classes;

import java.util.logging.Level;
import java.util.logging.Logger;
import org.cassandra.CassandraAccess;

/**
 *
 * @author marc
 */
public class Talk extends Activity {
    private String user;
    private String start;
    private String end;

    public static final String TALK_ACTIVITY="talk";

    public static final String ATTRIB_USER="user";
    public static final String ATTRIB_START="start";
    public static final String ATTRIB_END="end";

    public Talk(String user, String start, String end) {
        this.type = TALK_ACTIVITY;
        this.user = user;
        this.start = start;
        this.end = end;
    }

    public Talk(){
        this.type = TALK_ACTIVITY;
    }

    public String save(){
        String resp="";

        CassandraAccess ca=new CassandraAccess(CommonUtils.URL_DATABASE, CommonUtils.PORT_DATABASE, CommonUtils.BBBCONFERENCE_KEYSPACE);
        try {
            java.util.UUID timeuuid=CommonUtils.getTimeUUID();
            
            resp += ca.insertValue(CFNAME, CommonUtils.asByteArray(timeuuid),this.bbbconference.getUuid().toString(), ATTRIB_TYPE.getBytes("UTF-8"),this.getType());
            resp += ca.insertValue(CFNAME, CommonUtils.asByteArray(timeuuid),this.bbbconference.getUuid().toString(), ATTRIB_USER.getBytes("UTF-8"),this.getUser());
            resp+=ca.insertValue(CFNAME, CommonUtils.asByteArray(timeuuid),this.bbbconference.getUuid().toString() ,ATTRIB_START.getBytes("UTF-8"), this.getStart());
            resp+=ca.insertValue(CFNAME, CommonUtils.asByteArray(timeuuid),this.bbbconference.getUuid().toString() ,ATTRIB_END.getBytes("UTF-8"), this.getEnd());
        } catch (Exception ex) {
            Logger.getLogger(Join.class.getName()).log(Level.SEVERE, null, ex);
        }
        ca.closePoolCassandra();
        return resp;
    }

    /**
     * @return the user
     */
    public String getUser() {
        return user;
    }

    /**
     * @param user the user to set
     */
    public void setUser(String user) {
        this.user = user;
    }

    /**
     * @return the start
     */
    public String getStart() {
        return start;
    }

    /**
     * @param start the start to set
     */
    public void setStart(String start) {
        this.start = start;
    }

    /**
     * @return the end
     */
    public String getEnd() {
        return end;
    }

    /**
     * @param end the end to set
     */
    public void setEnd(String end) {
        this.end = end;
    }
}
